<template>
  <div class="hot-chart">
    <div class="chart-header">
      <span class="header-title">{{showData.title}}</span>
      <svg
        t="1628564915448"
        class="icon"
        viewBox="0 0 1024 1024"
        version="1.1"
        xmlns="http://www.w3.org/2000/svg"
        p-id="4332"
        width="16"
        height="16"
      >
        <path
          d="M512 0a512 512 0 1 0 0 1024A512 512 0 0 0 512 0z m0 896A384 384 0 0 1 512 128a384 384 0 0 1 0 768z m29.696-194.88c-11.136 10.112-24.96 17.344-31.488 15.36-6.08-1.792-9.536-7.424-8.384-13.056l89.344-248c7.424-31.488-12.736-60.16-55.424-63.872-44.8 0-110.976 40.128-151.232 90.944 0 6.08-1.344 21.12 0.128 30.208l53.632-54.208c11.008-10.176 23.808-17.344 30.336-15.424 6.592 1.92 10.112 8.384 8 14.464l-88.704 246.848c-10.176 28.864 9.152 57.152 56.192 63.616 68.928 0 109.888-39.168 150.208-89.984 0-6.08 2.368-22.08 0.96-31.104l-53.568 54.208zM575.744 192c-35.584 0-64.448 25.728-64.448 63.808 0 37.952 28.864 63.744 64.448 63.744 35.648 0 64.448-25.728 64.448-63.744 0-38.08-28.8-63.808-64.448-63.808z"
          p-id="4333"
          fill="#dbdbdb"
        ></path>
      </svg>
    </div>
    <div>
      <span class="search-count">{{showData.count}}</span>
      <span class="search-percent">{{showData.percent}}</span>
      <svg
        t="1628565785696"
        class="icon"
        viewBox="0 0 1024 1024"
        version="1.1"
        xmlns="http://www.w3.org/2000/svg"
        p-id="10465"
        width="12"
        height="12"
        v-if="showData.percent>0"
      >
        <path
          d="M660.650667 1024V438.912h210.986666L520.021333 0 168.405333 438.912H379.306667V1024z"
          fill="#d81e06"
        ></path>
      </svg>
      <svg
        t="1628565809446"
        class="icon"
        viewBox="0 0 1024 1024"
        version="1.1"
        xmlns="http://www.w3.org/2000/svg"
        p-id="11393"
        width="12"
        height="12"
        v-else
      >
        <path
          d="M384.65536 20.48v561.68448H182.14912L519.65952 1003.52l337.59232-421.35552h-202.5472V20.48z"
          fill="#1afa29"
        ></path>
      </svg>
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
import resize from '@/mixins/resize'
export default {
  name: 'HotChart',
  mounted() {
    this.myEcharts = echarts.init(this.$refs.charts)
    this.myEcharts.setOption({
      xAxis: {
        type: 'category',
        show: false,
        boundaryGap: false
      },
      yAxis: {
        show: false
      },
      series: [
        {
          type: 'line',
          smooth: true,
          data: this.showData.chartData,
          itemStyle: { opacity: 0 },
          lineStyle: {
            color: '#5470C7'
          },
          areaStyle: {
            color: {
              type: 'linear',
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              colorStops: [
                {
                  offset: 0,
                  color: '#E7EFFF'
                },
                {
                  offset: 1,
                  color: '#fff'
                }
              ],
              global: false
            }
          }
        }
      ],
      grid: {
        left: 0,
        right: 0,
        top: 0,
        bottom: 0
      },
      silent: true
    })
  },
  props: {
    showData: Object
  },
  mixins: [resize]
}
</script>

<style lang="sass" scoped>
.chart-header
  display: flex
  align-items: center
  color: #808080
  margin-bottom: 20px
.header-title
  margin-right: 20px

.search-count
  font-size: 25px
  margin-right: 30px

.search-percent
  color: #808080

.charts
  width: 100%
  height: 50px
  margin-top: 10px
</style>
